import { Component, Vue } from 'vue-property-decorator'
import axios from "@axios/project";
import { Project } from '@entity/project';
import Avatar from '@avatar'
import Tag from '@tag';

@Component({
    components: {
        Avatar, Tag
    }
})
export class HomeProjectsView extends Vue {

    /** 项目列表 */
    private homeProjects: Array<Project> = this.$store.getters.projectList();

    /**
     * 先拿本地缓存显示
     * 然后从服务器拉取数据
     * 最后将拉取到的数据存入本地
     */
    created() {
        axios.base.projectList().then((res: Array<Project>) => {
            this.homeProjects = res;
            this.$store.commit('addAllProjects', res);
        })
    }
    
}